import copy


# 将一个列表的数据复制到另一个列表中
def main_1(n):
    list1 = [1, 2, 3, 4, 5]
    list2 = []
    for i in range(n):
        list2.append(list1[i])
    list1[0] = 9
    print(list1, "\n", list2, "\n")


def main_2(n):
    list1 = [1, 2, 3, 4, 5]
    list2 = list1[:n]
    list2[0] = 9
    print(list1, "\n", list2, "\n")


def main_3():
    list1 = [1, 2, 3, 4, 5]
    list2 = list1
    list2[0] = 9
    print(list1, "\n", list2, "\n")


def main_4():
    list1 = [1, 2, 3, 4, 5]
    list2 = copy.copy(list1)
    list2[0] = 9
    print(list1, "\n", list2, "\n")


list3 = [1, 2, 3, [4, 5]]
list4 = copy.deepcopy(list3)
list4[3][0] = 9
list4[0] = 10
print(list3, "\n", list4, "\n")

if __name__ == "__main__":
    n = 5
    main_1(n)
    main_2(n)
    main_3()
    main_4()
